package net.zjitc.servlet.product;

import net.zjitc.domain.CategorySecond;
import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.SecondService;
import net.zjitc.service.impl.ProductServiceImpl;
import net.zjitc.service.impl.SecondServiceImpl;
import net.zjitc.utils.PageBean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * 2 * @Author: 洪瑶
 * 3 * @Date: 2018/11/1 8:50
 * 4
 */
@WebServlet(name = "FindPageServlet",urlPatterns = "/findPage")
public class FindPageServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        ProductService service = new ProductServiceImpl();
        List<Product> list = null;
        try {
            list = service.findAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        HttpSession session = request.getSession();
        request.setAttribute("page",list);
        request.getRequestDispatcher("common/product/list.jsp").forward(request,response);
    }
}
